# a = [3, 2, 11, -5]
# print(a[1])
# print(a[2])
# print(a[3])
# print(a[0] + a[1] + a[2] + a[3] + a[4])

# h = [3, 2, 11, -5]

# s = 1
# for i in range(4):
# s = s + h[i]
# print(s)

# h = [8, 6, 88, 2, 9]

# s = 1
# for i in range(len(h)):
# s = s * h[i]
# print(s)

# h = [8, 6, 88, 2, 9]
# min_h = h[0]
# for i in range(len(h)):
# if h[i] < min_h:
# min_h = h[i]
# print(min_h)

# h = [8, 6, 88, 2, 9]
# max_h = h[0]
# for i in range(len(h)):
# if h[i] > max_h:
# max_h = h[i]
# print(max_h)

# h = [2, 6, 88, 2, 9]
# min_h = h[0]
# for i in range(len(h)):
# if h[i] < min_h:
# min_h = h[i]
# max_h = h[0]
# for i in range(len(h)):
# if h[i] > max_h:
# max_h = h[i]
# for i in range(len(h)):
# if h[i] == min_h:
# h[i] = max_h
# print(h)


# h = [2, 6, 88, 2, 9]
# min_h = h[0]
# for i in range(len(h)):
# if h[i] < min_h:
# min_h = h[i]
# max_h = h[0]
# for i in range(len(h)):
# if h[i] > max_h:
# max_h = h[i]
# for i in range(len(h)):
# if h[i] == max_h:
# h[i] = min_h
# print(h)

import time


def bubble_sort(nums):
    swapped = True
    while swapped:
        swapped = False
        for i in range(len(nums) - 1):
            if nums[i] > nums[i + 1]:
                nums[i], nums[i + 1] = nums[i + 1], nums[i]

                swapped = True

def read2list(filename):
    file = open(filename, 'r')
    data = file.readlines()
    return data


def read2list_int(filename):
    file = open(filename, 'r')
    data = file.readlines()
    data = list(map(int, data))
    return data


# data = [62, 12, 2, 7, 6]
m1 = read2list_int("m1_sorted.txt")
print(m1)
bubble_sort(m1)
print(m1)

m2 = read2list_int("m2_reverse.txt")
print(m2)
bubble_sort(m2)
print(m2)

m3 = read2list_int("m3_shuffle.txt")
print(m3)
bubble_sort(m3)
print(m3)

t_start = time.time()
t_finish = time.time()
print("время", (t_finish - t_start) * 1000)
